<?php
// +----------------------------------------------------------------------------
// | Tke团队版权所属 [三十年河东三十年河西,莫欺少年穷.!]
// +----------------------------------------------------------------------------
// | Copyright (c) 2014 http://www.itdaodan.com All rights reserved.
// +----------------------------------------------------------------------------
// | Author: PHP@妖孽 <dino_ma@163.com>
// +----------------------------------------------------------------------------
/**
 * @todo 后台公用控制器
 * @since 2014-08-12
 */
namespace Admin\Controller;


class PublicController extends \Think\Controller {
	

    /**
     * 后台用户登录
     */
    public function login($login_name = null, $login_pwd = null){
		if(IS_POST){
			$obj_member = D('Member');
			$uid = $obj_member->login(trim($login_name), trim($login_pwd));
			if(0<$uid){
				$this->success('登录成功！', U('Index/index'));
			} else { //登录失败
				switch($uid) {
					case -1: $error = '用户不存在或被禁用！'; break; //系统级别禁用
					case -2: $error = '密码错误！'; break;
					default: $error = '未知错误！'; break; // 0-接口参数错误（调试阶段使用）
				}
				$this->error($error);
			}
		}else{
			if(is_login()){
				$this->redirect('Index/index');
			}else{
			    $browser = getBrowser();
			    //只对谷歌和火狐进行支持
			    if($browser == 'firefox' || $browser == 'chrome' || $browser == 'safari'){
    				$this->meta_title="家家户户活动管理平台";
    				$this->display();
			    }else{
			        $this->display('brower_error');
			    }
			}
		}
    }

    /**
     * @todo 退出登录
     */
    public function logout(){
        if(is_login()){
            D('Member')->logout();
            session('[destroy]');
            $this->success('退出成功！', U('login'));
        } else {
            $this->redirect('login');
        }
    }

    /**
     * @todo 验证码
     */
    public function verify(){
        $verify = new \Think\Verify();
        $verify->entry(1);
    }
}
